import 'package:flutter/material.dart';
import 'package:people_big_people/bean/testReq/HouseBean.dart';
import 'package:people_big_people/route/route_map.dart';

import '../../base/base_state.dart';

///gyzp
class Friend extends StatefulWidget {
  const Friend({Key? key}) : super(key: key);

  @override
  State<Friend> createState() => _FriendState();
}

class _FriendState extends BaseState<Friend> {
  List<HouseBean> houseList = [];

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    HouseBean houseBean = HouseBean();
    houseBean.name = "美之国花园";
    houseBean.url = "https://su.ke.com/ershoufang/107103585210.html?fb_expo_id=633245065002668033";
    houseBean.price = "215万  单价23329元每平";
    houseBean.currentPrice = "92.16平米";
    houseBean.targetPrice = "193万 21000元每平  首付+税68";
    houseList.add(houseBean);
    HouseBean houseBean1 = HouseBean();
    houseBean1.name = "美之国花园0 带阁楼";
    houseBean1.url = "https://su.ke.com/ershoufang/107104618055.html?fb_expo_id=633245065002668034";
    houseBean1.price = "215万  单价23768元每平";
    houseBean1.currentPrice = "90.46平米";
    houseBean1.targetPrice = "193万 21000元每平  首付+税68";
    houseList.add(houseBean1);
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: const BoxDecoration(color: Colors.white),
      child: ListView.separated(
        shrinkWrap: true,
        separatorBuilder: (context, index) {
          return Divider(
            height: 1,
            // Divider 高度，不是线的高度
            thickness: 1,
            // 线的高度
            color: index % 2 == 0 ? Colors.orange : Colors.blue,
            indent: 16,
            // 左侧间距
            endIndent: 16, // 右侧间距
          );
        },
        itemCount: houseList.length,
        addAutomaticKeepAlives: false,
        addRepaintBoundaries: false,
        itemBuilder: (BuildContext context, int index) {
          return SizedBox(
            width: double.infinity,
            child: GestureDetector(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Padding(
                    padding: const EdgeInsets.fromLTRB(10, 10, 10, 10),
                    child: Text(
                      houseList[index].name ?? "",
                      style: const TextStyle(fontSize: 16, color: Colors.black),
                    ),
                  ),
                  Padding(
                    padding: const EdgeInsets.fromLTRB(10, 0, 10, 10),
                    child: Text(
                      "当前价格：${houseList[index].price}",
                      style: const TextStyle(fontSize: 16, color: Colors.black),
                    ),
                  ),
                  Padding(
                    padding: const EdgeInsets.fromLTRB(10, 0, 10, 10),
                    child: Text(
                      "大小：${houseList[index].currentPrice}",
                      style: const TextStyle(fontSize: 16, color: Colors.black),
                    ),
                  ),
                  Padding(
                    padding: const EdgeInsets.fromLTRB(10, 0, 10, 10),
                    child: Text(
                      "目标价格：${houseList[index].targetPrice}",
                      style: const TextStyle(fontSize: 16, color: Colors.black),
                    ),
                  ),
                ],
              ),
              onTap: () {
                Navigator.of(context).pushNamed(router.webPage.routeName, arguments: {"url":houseList[index].url});
              },
            ),
          );
        },
      ),
    );
  }
}
